package com.imstlife.vending.utils;

import android.content.Context;

import com.imstlife.vending.activity.DrinkInfoActivity;

/**
 * Created by lihaifeng on 17/2/22.
 * 饮料记数工具类
 */

public class DrinkCountUtil {

    /**
     *
     * @param context
     * @param num
     * @param type 加:1 减：2  补满：3
     * @param value
     */
    public static int  updateCount(Context context,String num, int type,int value) {

        int count = SharePersistentUtil.getSharePersistentInt(context, Cof.APP_IMAGE_CACHE, num);
         int result =count;
        switch (type){
            case 1:
                result = count+value;

                break;
            case 2:
                 result = count-value;
                break;
            case 3:
               result = value;
                break;
        }
        SharePersistentUtil.saveSharePersistent(context, Cof.APP_IMAGE_CACHE, num, result);
        return result;

    }

    public static int  getDrinkCountByNum(Context context, String num){
        int count = SharePersistentUtil.getSharePersistentInt(context, Cof.APP_IMAGE_CACHE, num);
        return count;
    }

}
